home *** CD-ROM | disk | FTP | other *** search
- /* sftest.c */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
-
- #include "strftime.h"
-
- main(int argc, char *argv[])
- {
- char fs[10], s[80];
- struct tm *stime;
- time_t tt;
-
- time(&tt);
- stime = localtime(&tt);
-
- if (argc < 2)
- {
- printf("usage: %s c\n where c is a strftime format code\n", argv[0]);
- return 10;
- }
- fs[0] = '%';
- fs[2] = '\0';
- while(--argc)
- {
- fs[1] = **++argv;
- if (strftime(s, 80, fs, stime) == 0)
- {
- printf("string overflow ");
- }
- printf("for format \"%s\" strftime gives \"%s\"\n", fs, s);
- }
- return 0;
- }
-